﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using GoShopping.BLL;
using System.Net.Configuration;

public partial class SuperManager_SMTPSetting : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            bindEmailSet();
        }
    }

    /// <summary>
    /// 绑定Smtp设置
    /// </summary>
    void bindEmailSet()
    {
        SiteSetting site = new SiteSetting();
        SmtpSection Smtps = site.GetSmtpSection();
        txtSmptMane.Text = Smtps.Network.Host;
        password.Text = Smtps.Network.Password;
        txtpost.Text = Smtps.From;
        txtNum.Text = Smtps.Network.UserName;
    }
    /// <summary>
    /// 更新邮件设置的按钮事件
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUpdateEmail_Click(object sender, EventArgs e)
    {
        try
        {
            string host = txtSmptMane.Text.ToString();
            string pwd = password.Text.ToString();
            string userName = txtNum.Text.ToString();
            string from = txtpost.Text.ToString();
            SiteSetting site = new SiteSetting();
            site.SaveSmtpSection(host, userName, pwd, from);
            ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "click", "alert('更新成功!');", true);
        }
        catch
        {
            ScriptManager.RegisterStartupScript(UpdatePanel1, GetType(), "click", "alert('更新失败!');", true);
        }
    }
}
